(* Content-type: application/mathematica *)

(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)

(* CreatedBy='Mathematica 7.0' *)

(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[       145,          7]
NotebookDataLength[      6878,        189]
NotebookOptionsPosition[      6467,        171]
NotebookOutlinePosition[      6813,        186]
CellTagsIndexPosition[      6770,        183]
WindowFrame->Normal*)

(* Beginning of Notebook Content *)
Notebook[{

Cell[CellGroupData[{
Cell[BoxData[{
 RowBox[{
  RowBox[{"n", " ", "=", " ", "100000000.0"}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"k", " ", "=", " ", "3"}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"Array", "[", 
   RowBox[{"p", ",", " ", "k"}], "]"}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"For", " ", "[", 
    RowBox[{
     RowBox[{"i", " ", "=", "1"}], ",", 
     RowBox[{"i", " ", "\[LessEqual]", " ", "k"}], ",", " ", 
     RowBox[{"i", "++"}], ",", " ", 
     RowBox[{
      RowBox[{"p", "[", "i", "]"}], " ", "=", " ", 
      RowBox[{"Prime", "[", "i", "]"}]}]}], "]"}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"intLog", "[", 
     RowBox[{"b_", ",", " ", "x_"}], "]"}], " ", ":=", " ", 
    RowBox[{"IntegerPart", "[", 
     RowBox[{"Log", "[", 
      RowBox[{"b", ",", " ", "x"}], "]"}], "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"count", " ", "=", " ", "0"}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"try", "[", 
     RowBox[{"1", ",", " ", "y_"}], "]"}], ":=", " ", "\[IndentingNewLine]", 
    RowBox[{"(", "\[IndentingNewLine]", "\t", 
     RowBox[{
      RowBox[{"Print", "[", 
       RowBox[{
       "1", ",", " ", "\"\< \>\"", ",", " ", "y", ",", " ", "\"\< \>\"", ",", 
        " ", "\"\< \>\"", ",", " ", 
        RowBox[{"p", "[", "kk", "]"}], ",", " ", "\"\< \>\"", ",", " ", "y", 
        ",", " ", "\"\< \>\"", ",", " ", 
        RowBox[{
         RowBox[{"intLog", "[", 
          RowBox[{
           RowBox[{"p", "[", "kk", "]"}], ",", " ", "y"}], "]"}], "+", 
         "1"}]}], "]"}], ";", " ", "\[IndentingNewLine]", "\t", 
      RowBox[{"Return", "[", 
       RowBox[{
        RowBox[{"intLog", "[", 
         RowBox[{
          RowBox[{"p", "[", "kk", "]"}], ",", " ", "y"}], "]"}], "+", "1"}], 
       "]"}], ";"}], "\[IndentingNewLine]", ")"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"try", "[", 
    RowBox[{"kk_", ",", " ", "y_Real"}], "]"}], ":=", " ", 
   "\[IndentingNewLine]", 
   RowBox[{"(", "\[IndentingNewLine]", "\t", 
    RowBox[{
     RowBox[{"count", " ", "=", " ", "0"}], ";", "\[IndentingNewLine]", "\t", 
     RowBox[{"Print", "[", 
      RowBox[{
       RowBox[{"p", "[", "kk", "]"}], ",", " ", "\"\< \>\"", " ", ",", " ", 
       "y", ",", " ", "\"\< \>\"", ",", " ", 
       RowBox[{"intLog", "[", 
        RowBox[{
         RowBox[{"p", "[", "kk", "]"}], ",", " ", "y"}], "]"}], ",", " ", 
       "\"\< \>\"", ",", " ", "count"}], "]"}], ";", "\[IndentingNewLine]", 
     "\t", 
     RowBox[{"For", "[", 
      RowBox[{
       RowBox[{"ak", " ", "=", " ", "0"}], ",", " ", 
       RowBox[{"ak", " ", "\[LessEqual]", " ", 
        RowBox[{"intLog", "[", 
         RowBox[{
          RowBox[{"p", "[", "kk", "]"}], ",", " ", "y"}], "]"}]}], ",", " ", 
       RowBox[{"ak", "++"}], ",", " ", 
       RowBox[{"count", " ", "+=", " ", 
        RowBox[{"try", "[", 
         RowBox[{
          RowBox[{"kk", "-", "1"}], ",", " ", 
          RowBox[{"y", "/", 
           RowBox[{"(", 
            RowBox[{
             RowBox[{"p", "[", "kk", "]"}], "^", "ak"}], ")"}]}]}], "]"}]}]}],
       "]"}], ";", "\[IndentingNewLine]", "\t", 
     RowBox[{"Print", "[", 
      RowBox[{
       RowBox[{"p", "[", "kk", "]"}], ",", " ", "\"\< \>\"", " ", ",", " ", 
       "y", ",", " ", "\"\< \>\"", ",", " ", 
       RowBox[{"intLog", "[", 
        RowBox[{
         RowBox[{"p", "[", "kk", "]"}], ",", " ", "y"}], "]"}], ",", " ", 
       "\"\< \>\"", ",", " ", "count"}], "]"}], ";", "\[IndentingNewLine]", 
     "\t", 
     RowBox[{"Return", "[", "count", "]"}], ";"}], "\[IndentingNewLine]", 
    ")"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"Print", "[", 
   RowBox[{"try", "[", 
    RowBox[{"3", ",", "15.0"}], "]"}], "]"}], ";"}]}], "Input",
 CellChangeTimes->{{3.4477131272695255`*^9, 3.4477131331215253`*^9}}],

Cell[BoxData[
 RowBox[{
  RowBox[{"SetDelayed", "::", "\<\"write\"\>"}], 
  RowBox[{
  ":", " "}], "\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"Tag \\\\\\\"\\\", \
\\\"MT\\\"]\\)\[NoBreak]\\!\\(\\*StyleBox[\\!\\(Times\\), \\\"MT\\\"]\\)\
\[NoBreak]\\!\\(\\*StyleBox[\\\"\\\\\\\" in \\\\\\\"\\\", \\\"MT\\\"]\\)\
\[NoBreak]\\!\\(\\*StyleBox[\\!\\(\\(\\((4\\\\ Null)\\)\\)[\\(\\(1, y_\\)\\)]\
\\), \\\"MT\\\"]\\)\[NoBreak]\\!\\(\\*StyleBox[\\\"\\\\\\\" is Protected.\\\\\
\\\"\\\", \\\"MT\\\"]\\) \\!\\(\\*ButtonBox[\\\"\[RightSkeleton]\\\", \
ButtonStyle->\\\"Link\\\", ButtonFrame->None, \
ButtonData:>\\\"paclet:ref/message/General/write\\\", ButtonNote -> \
\\\"SetDelayed::write\\\"]\\)\"\>"}]], "Message", "MSG",
 CellChangeTimes->{
  3.4477130777275257`*^9, {3.4477131281025257`*^9, 3.4477131335575256`*^9}}],

Cell[BoxData[
 RowBox[{
  RowBox[{"SetDelayed", "::", "\<\"write\"\>"}], 
  RowBox[{
  ":", " "}], "\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"Tag \\\\\\\"\\\", \
\\\"MT\\\"]\\)\[NoBreak]\\!\\(\\*StyleBox[\\!\\(Times\\), \\\"MT\\\"]\\)\
\[NoBreak]\\!\\(\\*StyleBox[\\\"\\\\\\\" in \\\\\\\"\\\", \\\"MT\\\"]\\)\
\[NoBreak]\\!\\(\\*StyleBox[\\!\\(\\(\\((4\\\\ Null)\\)\\)[\\(\\(kk_, \
y_Real\\)\\)]\\), \\\"MT\\\"]\\)\[NoBreak]\\!\\(\\*StyleBox[\\\"\\\\\\\" is \
Protected.\\\\\\\"\\\", \\\"MT\\\"]\\) \
\\!\\(\\*ButtonBox[\\\"\[RightSkeleton]\\\", ButtonStyle->\\\"Link\\\", \
ButtonFrame->None, ButtonData:>\\\"paclet:ref/message/General/write\\\", \
ButtonNote -> \\\"SetDelayed::write\\\"]\\)\"\>"}]], "Message", "MSG",
 CellChangeTimes->{
  3.4477130777275257`*^9, {3.4477131281025257`*^9, 3.4477131335595255`*^9}}],

Cell[BoxData[
 RowBox[{
  RowBox[{"(", 
   RowBox[{"4", " ", "Null"}], ")"}], "[", 
  RowBox[{"3", ",", "15.`"}], "]"}]], "Print",
 CellChangeTimes->{
  3.4477130777325253`*^9, {3.4477131281085253`*^9, 3.4477131335615253`*^9}}]
}, Open  ]]
},
WindowSize->{601, 750},
WindowMargins->{{244, Automatic}, {82, Automatic}},
FrontEndVersion->"7.0 for Microsoft Windows (32-bit) (November 10, 2008)",
StyleDefinitions->"Default.nb"
]
(* End of Notebook Content *)

(* Internal cache information *)
(*CellTagsOutline
CellTagsIndex->{}
*)
(*CellTagsIndex
CellTagsIndex->{}
*)
(*NotebookFileOutline
Notebook[{
Cell[CellGroupData[{
Cell[567, 22, 4036, 106, 532, "Input"],
Cell[4606, 130, 803, 14, 21, "Message"],
Cell[5412, 146, 809, 14, 21, "Message"],
Cell[6224, 162, 227, 6, 23, "Print"]
}, Open  ]]
}
]
*)

(* End of internal cache information *)
